<?php
defined('IN_TS') or die('Access Denied.');

//小组首页

if($TS_USER['user'] == ''){

	//推荐小组列表
	$arrRecommendGroup = $new['group']->getRecommendGroup('7');
	//最新10个小组
	$arrNewGroup = $new['group']->getNewGroup('10');
	
	//小组分类
	$arrCate = $new['group']->getCates();
	
	//友情链接
	$arrLink = aac('links',$DB)->getLinks('1');
	
	$title = $TS_SITE['base']['site_subtitle'];

	include TmooTemplate("index");
	
}else{

	$userid = intval($TS_USER['user']['userid']);
	if($userid == '0') header("Location: index.php");
	
	//我的小组
	$myGroup = $DB->fetch_all_assoc("select * from ".dbprefix."app_group_users where userid='$userid'");
	
	if($myGroup != ''){
	
		//我加入的小组
		$myGroups = $DB->fetch_all_assoc("select * from ".dbprefix."app_group_users where userid='$userid' limit 12");
		
		if(is_array($myGroups)){
			foreach($myGroups as $key=>$item){
				$arrMyGroup[] = $new['group']->getOneGroup($item['groupid']);
			}
		}
		
		$myCreateGroup = $DB->fetch_all_assoc("select * from ".dbprefix."app_group where userid='$userid' limit 12");
		//我管理的小组
		if(is_array($myCreateGroup)){
			foreach($myCreateGroup as $key=>$item){
				
					$arrMyAdminGroup[] = $new['group']->getOneGroup($item['groupid']);
				
			}
		}
		
		//我加入的所有小组的话题
		
		if(is_array($myGroup)){
			foreach($myGroup as $item){
				$arrGroup[] = $item['groupid'];
			}
		}
		
		$strGroup = implode(',',$arrGroup);

		
		$arrTopic = $DB->fetch_all_assoc("select * from ".dbprefix."app_group_topics where groupid in ($strGroup) and isshow='0' order by istop desc,uptime desc limit 50");
	
	}
	
	$title = '我的小组';

	include TmooTemplate("test");
}